<!--
 * @description  : 案件-运输信息-面单信息
 * @descriptionDetail: 案件-运输信息-面单信息
 * @copyright    : 广西烟草
 * @author       : 伍盟博
 * @create       : 2022-10-12 21:31:06
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :custom-back="goBack" :isWhite="true" backText="返回" :title="typeInfo.typeName"></theme-navbar>
    <!-- #endif -->
    <view class="content">
      <view class="party-info-content">
        <view class="party-info-box">
          <u-form :model="involvedForm" :rules="rules" :errorType="errorType" ref="uForm">
            <view style="width: calc(100% + 30px);">
              <form-section title="基本信息"></form-section>
            </view>
            <u-form-item label="面单号" :label-position="labelPosition" :required="isTrue" prop="billCode">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.billCode" />
            </u-form-item>
            <u-form-item label="所属快递公司" :label-position="labelPosition">
              <auto-input
                absIndex="1"
                :searchData="searchData"
                absClass="caseFromClass"
                :disabled="isDisabled"
                placeholder="快递公司模糊查询"
                v-model="involvedForm.expressName"
                @choiceAutoItem="choiceAutoItem"
                style="width:100%"
              >
              </auto-input>
            </u-form-item>
            <u-form-item label="包裹数量" :label-position="labelPosition">
              <u-input placeholder="请输入" type="number" :disabled="isDisabled" v-model="involvedForm.packageNum" />
            </u-form-item>
            <u-form-item label="车辆关联" :label-position="labelPosition">
              <auto-input
                absIndex="2"
                :searchData="searchDataCar"
                absClass="caseFromClass"
                :disabled="isDisabled"
                placeholder="关联车辆模糊查询"
                v-model="involvedForm.carName"
                @choiceAutoItem="choiceAutoItem"
                style="width:100%"
              >
              </auto-input>
            </u-form-item>
            <u-form-item label="查获人" :label-position="labelPosition" prop="getPerson">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.getPerson" />
            </u-form-item>
            <u-form-item label="查获人电话" :label-position="labelPosition" prop="getPersonTel">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.getPersonTel" />
            </u-form-item>
            <u-form-item label="包装形式" :label-position="labelPosition">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.packageStyle" />
            </u-form-item>
            <u-form-item label="查获地址" :label-position="labelPosition">
              <view class="logi-addr">
                <u-input
                  type="select"
                  :disabled="true"
									:custom-style="pointerStyle"
                  placeholder="查获地选择"
                  v-model="seizurePlace"
                  @click="clickAreaShow('trS')"
                ></u-input>
                <u-line :color="$theme.u_border_color" style="margin: 10rpx 0;"></u-line>
                <u-row gutter="16">
                  <u-col span="12">
                    <u-input :disabled="isDisabled" :border="true" placeholder="请输入详情地址" v-model="involvedForm.distributionAddr"></u-input>
                  </u-col>
                </u-row>
              </view>
            </u-form-item>
            <u-gap :marginRight="getGapMarginRowNumber()" :marginLeft="getGapMarginRowNumber()" :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            <fsection title="发件信息"></fsection>
            <u-form-item label="发件人" :label-position="labelPosition" prop="sender">
              <u-button
                  plain
                  style="position: absolute;top: 11px;right: 0;"
                  class="step-right-lay"
                  type="primary"
                  size="mini"
                  @click="showHisBill('sender')"
              >
                <view>历史面单</view>
              </u-button>
              <auto-input
                  :disabled="isDisabled"
                  absIndex="4"
                  :searchData="searchEnterPerson"
                  absClass="caseFromClass"
                  placeholder="请输入"
                  v-model="involvedForm.sender"
                  @choiceAutoItem="choiceAutoItemPerson"
                  style="width:100%"
              >
              </auto-input>
<!--              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.sender" />-->
            </u-form-item>
            <u-form-item label="发件人电话" :label-position="labelPosition" prop="sendTel">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.sendTel" />
            </u-form-item>
            <u-form-item label="发件时间" :label-position="labelPosition">
              <u-input placeholder="请选择" :disabled="true" :custom-style="pointerStyle" v-model="involvedForm.sendTime" @click="dateChange('owner')">
              </u-input>
            </u-form-item>
            <u-form-item label="发件地址" :label-position="labelPosition">
              <view class="logi-addr">
                <u-input
                  type="select"
                  :disabled="true"
									:custom-style="pointerStyle"
                  placeholder="请选择"
                  v-model="ownerCoinNames"
                  @click="clickAreaShow('owner')"
                ></u-input>
                <u-line :color="$theme.u_border_color" style="margin: 10rpx 0;"></u-line>
                <u-row gutter="16">
                  <u-col span="12">
                    <u-input :disabled="isDisabled" :border="true" placeholder="请输入详细地址" v-model="involvedForm.sendAddress"></u-input>
                  </u-col>
                </u-row>
              </view>
            </u-form-item>
            <u-form-item label="寄件站点" :label-position="labelPosition" prop="sendSite">
              <u-input placeholder="请输入寄件站点" :disabled="isDisabled" v-model="involvedForm.sendSite" />
            </u-form-item>
            <u-gap :marginRight="getGapMarginRowNumber()" :marginLeft="getGapMarginRowNumber()" :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            <fsection title="揽件信息"></fsection>
            <u-form-item label="揽件人" :label-position="labelPosition" prop="packager">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.packager" />
            </u-form-item>
            <u-form-item label="揽件人电话" :label-position="labelPosition" prop="packagerTel">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.packagerTel" />
            </u-form-item>
            <u-form-item label="揽件时间" :label-position="labelPosition">
              <u-input placeholder="请选择" :disabled="true" :custom-style="pointerStyle" v-model="involvedForm.packagerTime" @click="dateChange('Canvass')">
              </u-input>
            </u-form-item>
            <u-form-item label="揽件站点" :label-position="labelPosition" prop="packagerSite">
              <u-input placeholder="请输入揽件站点" :disabled="isDisabled" v-model="involvedForm.packagerSite" />
            </u-form-item>
            <u-gap :marginRight="getGapMarginRowNumber()" :marginLeft="getGapMarginRowNumber()" :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            <fsection title="派件信息"></fsection>
            <u-form-item label="派件人" :label-position="labelPosition" prop="dispatcher">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.dispatcher" />
            </u-form-item>
            <u-form-item label="派件人电话" :label-position="labelPosition" prop="dispatcherTel">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.dispatcherTel" />
            </u-form-item>
            <u-form-item label="派件时间" :label-position="labelPosition">
              <u-input placeholder="请选择" :disabled="true" :custom-style="pointerStyle" v-model="involvedForm.dispatcherTime" @click="dateChange('dispatcher')">
              </u-input>
            </u-form-item>
            <u-form-item label="派件地址" :label-position="labelPosition">
              <view class="logi-addr">
                <u-input
                  type="select"
                  :disabled="true"
									:custom-style="pointerStyle"
                  placeholder="请选择"
                  v-model="driverCoinNames"
                  @click="clickAreaShow('driver')"
                ></u-input>
                <u-line :color="$theme.u_border_color" style="margin: 10rpx 0;"></u-line>
                <u-row gutter="16">
                  <u-col span="12">
                    <u-input :disabled="isDisabled" :border="true" placeholder="请输入详细地址" v-model="involvedForm.dispatcherAddress"></u-input>
                  </u-col>
                </u-row>
              </view>
            </u-form-item>
            <u-form-item label="派件站点" :label-position="labelPosition" prop="dispatcherSite">
              <u-input placeholder="请输入派件站点" :disabled="isDisabled" v-model="involvedForm.dispatcherSite" />
            </u-form-item>
            <u-gap :marginRight="getGapMarginRowNumber()" :marginLeft="getGapMarginRowNumber()" :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            <fsection title="收件信息"></fsection>
            <u-form-item label="收件人" :label-position="labelPosition" prop="receiver">
              <u-button
                  plain
                  style="position: absolute;top: 11px;right: 0;"
                  class="step-right-lay"
                  type="primary"
                  size="mini"
                  @click="showHisBill('receiver')"
              >
                <view>历史面单</view>
              </u-button>
              <auto-input
                  :disabled="isDisabled"
                  absIndex="4"
                  :searchData="searchEnterPerson"
                  absClass="caseFromClass"
                  placeholder="请输入"
                  v-model="involvedForm.receiver"
                  @choiceAutoItem="choiceReceiverPerson"
                  style="width:100%"
              >
              </auto-input>
<!--              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.receiver" />-->
            </u-form-item>
            <u-form-item label="收件人电话" :label-position="labelPosition" prop="receiverTel">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.receiverTel" />
            </u-form-item>
            <u-form-item label="收件时间" :label-position="labelPosition">
              <u-input placeholder="请选择" :disabled="true" :custom-style="pointerStyle" v-model="involvedForm.receiverTime" @click="dateChange('receive')">
              </u-input>
            </u-form-item>
            <u-form-item label="收件地址" :label-position="labelPosition">
              <view class="logi-addr">
                <u-input
                  type="select"
                  :disabled="true"
									:custom-style="pointerStyle"
                  placeholder="请选择"
                  v-model="trECoinNames"
                  @click="clickAreaShow('trE')"
                ></u-input>
                <u-line :color="$theme.u_border_color" style="margin: 10rpx 0;"></u-line>
                <u-row gutter="16">
                  <u-col span="12">
                    <u-input :disabled="isDisabled" :border="true" placeholder="请输入详细地址" v-model="involvedForm.receiverAddress"></u-input>
                  </u-col>
                </u-row>
              </view>
            </u-form-item>
            <u-form-item label="收件站点" :label-position="labelPosition" prop="receiverSite">
              <u-input placeholder="请输入收件站点" :disabled="isDisabled" v-model="involvedForm.receiverSite" />
            </u-form-item>
            <u-gap :marginRight="getGapMarginRowNumber()" :marginLeft="getGapMarginRowNumber()" :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            <fsection title="其他信息"></fsection>
            <u-form-item :label-position="labelPosition" label="备注">
              <u-input type="textarea" height="100" :auto-height="true" placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.remark" />
            </u-form-item>
            <u-form-item label="图片信息" :label-position="labelPosition">
              <view class="zk-img-content">
                <m-upload
                    v-if="showUploadImg"
                  :deletable="true"
                  :maxCount="picIds"
                  width="150rpx"
                  height="150rpx"
                  :file-list="fileList"
                    :disabled="isDisabled"
                  :multiple="true"
                  index="fileList"
                  :uploadParam="{'fiGroupCode':$FILE_GROUP_TYPE.c_case_express}"
                  upApiUrl="uploadBase64ForApp"
                  ref="filePicUpload"
                  @on-list-change="changeUpload"
                >
                </m-upload>
              </view>
            </u-form-item>
            <view></view>
            <u-gap :marginRight="getGapMarginRowNumber()" :marginLeft="getGapMarginRowNumber()" :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            <form-section @rightTap="addGoodTap" title="关联物品" :customStyle="customStyle" rightIcon="plus-circle" :rightIconSize="40"></form-section>
            <view class="card" v-for="(item, index) in clients" :key="item.id">
              <u-swipe-action
                :index="index"
                :show="item.show"
                :options="options"
                :disabled="isDisabled"
                @click="handlerDeleteClient(item)"
                @open="handlerOpen(index)"
              >
                <clientItem :client="item"></clientItem>
              </u-swipe-action>
            </view>
          </u-form>
        </view>
      </view>
      <view class="space-content"></view>
      <view class="submit-btns btn-other-cls">
        <u-button class="u-btn" type="primary" v-if="typeInfo.type!='view'" @click="confirm('01')">
          保存
        </u-button>
        <u-button class="u-btn" type="primary" v-if="typeInfo.type!='view' && typeInfo.type!='edit'" @click="confirm('02')">
          保存并添加
        </u-button>
      </view>
    </view>
    <!-- 行政区划选择 -->
    <u-popup mode="bottom" height="80%" v-model="nativeNameSelectShow">
      <area-select @choose="nativeNameSelectShowComfir"></area-select>
    </u-popup>
    <!-- 时间 -->
    <u-picker mode="time" :params="paramsTime" v-model="dateRange" @confirm="handlerSearchDate" @cancel="showTime = false"></u-picker>
  </view>
</template>

<script>
import TcarInfo from "@/declare/case/TcarInfo.js";
import commonService from "@/service/common/common.service";
import caseService from '@/service/case/case.service.js';
import areaSelect from "@/components/area-select.vue";
import FormSection from "@/components/form-section.vue";
import mUpload from '@/components/m-upload.vue';
import AutoInput from "@/components/autoInput.vue";
import fsection from "@/components/form-section.vue";
import clientItem from './clientItem.vue'
export default {
  components:{
    areaSelect,
    FormSection,
    mUpload,
    AutoInput,
    fsection,
    clientItem,
  },
  data(){
    return {
      nativeNameSelectShow: false,// 行政区选择框是否打开
      ownerCoinNames: "",// 发件地址
      driverCoinNames: "",// 派件地址
      seizurePlace: "",// 查获地选择
      trECoinNames: "",// 收件地址
      carChecked:false,// 是否改装车
      isDisabled:false, // 表单是否禁用
      involvedForm:TcarInfo.createNew(),
      rules:{
        billCode: [{
          required: true,
          message: '请输入单号',
          trigger: ['change', 'blur',],
        },],
        getPerson: [{
          message:"查获人格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }{
              let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
              return regs.test(value);
            }
          },
        },],
        sender: [{
          message:"发件人格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }{
              let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
              return regs.test(value);
            }
          },
        },],
        packager: [{
          message:"揽件人格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }{
              let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
              return regs.test(value);
            }
          },
        },],
        dispatcher: [{
          message:"派件人格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }{
              let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
              return regs.test(value);
            }
          },
        },],
        receiver: [{
          message:"收件人格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }{
              let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
              return regs.test(value);
            }
          },
        },],
        getPersonTel: [{
          message:"电话格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }{
              return this.$u.test.mobile(value) || this.$u.test.tel(value);
            }
          },
        },],
        sendTel: [{
          message:"电话格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }{
              return this.$u.test.mobile(value) || this.$u.test.tel(value);
            }
          },
        },],
        packagerTel: [{
          message:"电话格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }{
              return this.$u.test.mobile(value) || this.$u.test.tel(value);
            }
          },
        },],
        dispatcherTel: [{
          message:"电话格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }{
              return this.$u.test.mobile(value) || this.$u.test.tel(value);
            }
          },
        },],
        receiverTel: [{
          message:"电话格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }{
              return this.$u.test.mobile(value) || this.$u.test.tel(value);
            }
          },
        },],
      },
      errorType: ['border-bottom','message',],
      isTrue: true,
      labelPosition:"top",
      activeColor: this.$u.color['primary'],
      border: false,
      typeInfo:{},// 类型 添加/编辑
      areaType:'',// 行政区划弹窗类型
      fileList: [],
      picIds: '20',
      iconStyle:{
        color: '#c0c4cc',
      },
      dateRange:false,
      dateStatus:"", // 控制时间类型
      customStyle:{
        padding:"20rpx 0rpx",
      },
      clients: [], // 关联物品数据
      options: [
        {
          text: '删除',
          style: {
            backgroundColor: '#dd524d',
          },
        },
      ],
      // 模式
      paramsTime: {
        year: true,
        month: true,
        day: true,
        hour: true,
        minute: true,
        second: true,
      },
			// h5端部分浏览器input设置disabled后点击事件失效 2023-10-26 fsx start
			pointerStyle: {
			  marginRight: "5px",
				pointerEvents: "none !important"
			},
			// h5端部分浏览器input设置disabled后点击事件失效 2023-10-26 fsx end
      showUploadImg: true
    }
  },
  onReady() {
    this.$refs.uForm.setRules(this.rules);
  },
  // 加载初始周期方法
  onLoad() {
    let prevParam =  this.getRouteParam();
    console.log('prevParam', prevParam)
    this.involvedForm.caseUuid = prevParam.caseUuid;
    if (prevParam.type) {
      this.typeInfo.type = prevParam.type;
      if (prevParam.type !== 'view') {
        this.typeInfo.typeName = prevParam.type == 'add' ? "添加面单信息" :  "编辑面单信息";
        this.isDisabled = false
      } else {
        this.typeInfo.typeName = "查看面单信息"
        this.isDisabled = true
      }
      this.updateMixinTitle(this.typeInfo.typeName);
    } else {
      this.typeInfo = {};
    }
    if(prevParam.param){
      this.involvedForm =  prevParam.param;
      if (this.involvedForm.photo) {
        let photoArr = this.involvedForm.photo.split(',');
        photoArr.forEach((val) => {
          this.fileList.push({
            gfiId: val,
          });
        });
      }
    }
  },
  mounted() {
    this.init();
    this.loadFaceOrder();
  },
  methods:{
    init() {
      this.initAreaData(this.involvedForm.dispatcherProvCode,this.involvedForm.dispatcherCityCode,this.involvedForm.dispatcherCountyCode,'driverCoinNames');
      this.initAreaData(this.involvedForm.sendProvCode,this.involvedForm.sendCityCode,this.involvedForm.sendCountyCode,'ownerCoinNames');
      this.initAreaData(this.involvedForm.getProvCode,this.involvedForm.getCityCode,this.involvedForm.getCountyCode,'seizurePlace');
      this.initAreaData(this.involvedForm.receiverProvCode,this.involvedForm.receiverCityCode,this.involvedForm.receiverCountyCode,'trECoinNames');
    },
    // 选择行政区划弹窗
    clickAreaShow(type){
      if (this.isDisabled) {
        return false
      }
      this.areaType = type;
      this.nativeNameSelectShow = true;
    },
    getGapMarginRowNumber(){
      return "-" + this.$theme.cm_content_paddng_row.replace('rpx', '');
    },
    initAreaData(provCode,cityCode,countyCode,name){
      if(!this.$u.test.isEmpty(provCode) && !this.$modal.isMuniCity(provCode)){
        this[name] = commonService.getPersonLocal(provCode, true).areaName || "";
      }
      if(!this.$u.test.isEmpty(cityCode)){
        this[name] += commonService.getPersonLocal(cityCode, true).areaName || "";
      }
      if(!this.$u.test.isEmpty(countyCode)){
        this[name] += commonService.getPersonLocal(countyCode, true).areaName || "";
      }
    },
    nativeNameSelectShowComfir(areas) {
      switch (this.areaType) {
      case 'owner':
        this.fromDataCopy('ownerCoinNames','sendProv','sendCity','sendCounty',areas);
        break;
      case 'driver':
        this.fromDataCopy('driverCoinNames','dispatcherProv','dispatcherCity','dispatcherCounty',areas);
        break;
      case 'trS':
        this.fromDataCopy('seizurePlace','getProv','getCity','getCounty',areas);
        break;
      case 'trE':
        this.fromDataCopy('trECoinNames','receiverProv','receiverCity','receiverCounty',areas);
        break;
      }

      this.nativeNameSelectShow = false;
    },
    fromDataCopy(areaName,pro,city,coun,areas){
      if(this.$modal.isMuniCity(areas[0].proCode)){
        this[areaName] = [areas[0].admdivName, areas[0].countryName,].join("");
      }else{
        this[areaName] = [areas[0].proName, areas[0].admdivName, areas[0].countryName,].join("");
      }
      this.involvedForm[pro + 'Code'] = areas[0].proCode;
      this.involvedForm[pro + 'Name'] = areas[0].proName;
      this.involvedForm[city + 'Code'] = areas[0].admdivCode;
      this.involvedForm[city + 'Name'] = areas[0].admdivName;
      this.involvedForm[coun + 'Code'] = areas[0].countryCode;
      this.involvedForm[coun + 'Name'] = areas[0].countryName;
    },
    choiceAutoItem(itm, index){
      if(index == '1'){
        this.involvedForm.expressName = itm.name;
        this.involvedForm.expressUuid = itm.value;
      }else if(index == '2'){
        this.involvedForm.carName = itm.name;
        this.involvedForm.carUuid = itm.value;
      }
    },
    searchData(txt){
      let params = {
        page:1,
        limit:10,
        name:txt,
      }
      return new Promise((resolve, reject) => {
        caseService.getCompanyIdAndNameList(params).then(res => {
          if(res.success){
            let tmp  = res.data;
            tmp.forEach(itm => {
              itm.name = [itm.text,].join("");
              itm.id = itm.value;
            });
            if(!res.data.length){
              this.involvedForm.expressName = "";
            }
            // console.log('===' + JSON.stringify(tmp));
            resolve(tmp);
          }else{
            resolve([]);
          }
        }).catch(err => {
          resolve([]);
        });
      });
    },
    searchDataCar(txt){
      let params = {
        page:1,
        limit:10,
        name:txt,
      }
      return new Promise((resolve, reject) => {
        caseService.getCarList(params,this.involvedForm.caseUuid).then(res => {
          if(res.success){
            let tmp  = res.data;
            tmp.forEach(itm => {
              itm.name = [itm.text,].join("");
              itm.id = itm.value;
            });
            if(!res.data.length){
              this.involvedForm.carName = "";
            }
            // console.log('===' + JSON.stringify(tmp));
            resolve(tmp);
          }else{
            resolve([]);
          }
        }).catch(err => {
          resolve([]);
        });
      });
    },
    dateChange(id){
      this.dateStatus = id;
      this.dateRange = true;
    },
    handlerSearchDate(e){
      let time = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute + ":" + e.second;
      switch (this.dateStatus) {
      case 'owner':
        this.involvedForm.sendTime = time;
        break;
      case 'Canvass':
        this.involvedForm.packagerTime = time;
        break;
      case 'dispatcher':
        this.involvedForm.dispatcherTime = time;
        break;
      case 'receive':
        this.involvedForm.receiverTime = time;
        break;
      }
    },
    addGoodTap(){
      if (this.isDisabled) {
        return false
      }
      this.setRouteParam(this.clients);
      this.$u.route('pages/case/caseInfoTemp/relatedItem?caseUuid=' + this.involvedForm.caseUuid);
    },
    // 关联物品列表
    loadFaceOrder(){
      if (!this.involvedForm.uuid) {
        return false
      }
      return new Promise((resolve,reject) => {
        caseService.queryListByBill(this.involvedForm.caseUuid,this.involvedForm.uuid).then(res => {
          if(res.success){
            res.data.forEach((itm) => {
              itm.show = false;
              // itm.swiperDisabled = false;
            });
            this.clients = res.data;
            // resolve({ data: {list: res.data, totalCount : res.count,},});
          }else{
            this.$modal.alert(res.msg);
            // resolve({ data: {list: [], totalCount : 0,},});
          }
        }).catch(e => {
          this.$u.toast('请求失败:' + e);
          // resolve({
          //   count: 0,
          //   data:[],
          // });
        });
      })
    },
    // 删除选中的客户
    handlerDeleteClient(cItem) {
      this.clients = this.clients.filter(c => c.goodsDtlUuid != cItem.goodsDtlUuid);
    },
    handlerOpen(idx) {
      this.clients.map((c, i) => {
        c.show = i == idx;
      });
      this.$forceUpdate();
      // this.$nextTick(() => this.clients = Object.assign([], this.clients));
    },
    updateBackState(param){
      this.clients = param.refresh;
    },
    // 确认
    confirm(type){
      let self = this;
      this.$refs.uForm.validate(valid => {
        if (valid) {
          // let {toJsonStr,updateContent,updateTime,...params} = self.involvedForm;
          let params = {...self.involvedForm,goodsList:this.clients,}
          let ids = [];
          if(this.fileList.length > 0){
            this.fileList.forEach((item) => {
              ids.push(item.gfiId);
            });
            params.photo = ids.join(',');
          }
          console.log(params);
          this.$modal.showLoading('正在保存...');
          caseService.saveFaceOrder(params).then(res => {
            if(res.success){
              this.$modal.hideLoading();
              if (type === '01') {
                self.backPrev({
                  paramKey: "formItem",
                  param :{
                    type:'faceOrder',
                  },
                });
              } else if (type === '02') {
                this.involvedForm = TcarInfo.createNew();
                this.fileList = [];
                this.init();
                this.showUploadImg = false;
                this.$nextTick(() => {
                  this.showUploadImg = true;
                  this.clients = []
                })
              }
            }else{
              this.$u.toast(res.msg);
            }
          }).catch(err => {
            this.$u.toast(err);
          })
        }
      });
    },
    // 上传/删除图片事件
    changeUpload(list, key) {
      if (list.length > 0) {
        this.fileList = [...list,];
      } else {
        this.fileList = [];
      }
    },
    searchEnterPerson(txt) {
      let params = {
       name:txt
      }
      return new Promise((resolve, reject) => {
        caseService.getLikeName(params).then(res => {
          if(res.success){
            let tmp  = res.data;
            tmp.forEach(itm => {
              itm.partyName = itm.name;
              itm.name = itm.name + '   ' + itm.phone;
              itm.id = itm.phone;
            });
            resolve(tmp);
          }else{
            resolve([]);
          }
        }).catch(err => {
          resolve([]);
        });
      });
    },
    // 发件人
    choiceAutoItemPerson(item) {
      console.log('item', item)
      this.involvedForm.sender = item.partyName;
      this.involvedForm.sendTel = item.phone;
    },
    // 收件人
    choiceReceiverPerson(item) {
      this.involvedForm.receiver = item.partyName;
      this.involvedForm.receiverTel = item.phone;
    },
    goBack() {
      this.backPrev({
        paramKey: "formItem",
        param :{
          type:'faceOrder',
        },
      });
    },
    showHisBill(type){
      let name = this.involvedForm[type];
      if (type === 'sender') {
        if (!this.involvedForm.sender) {
          this.$u.toast('请输入发件人');
          return false
        }
      } else if (type === 'receiver') {
        if (!this.involvedForm.receiver) {
          this.$u.toast('请输入收件人');
          return false
        }
      }
      this.$u.route('pages/case/caseInfoTemp/hisBillList?name=' + name);
    }
  },
}
</script>

<style lang="scss" scoped>
@import "../case_common.scss";
.page{ padding:0; }
.logi-addr{
display: flex;
 flex-direction: column;
 width: 100%;
}
.secion-title{
	font-size: .9rem;
	font-weight: 500;
	padding: 30rpx 0px 20rpx;
}
.u-sub-btn{
	width: 99%;
}
.card{
  margin: 14rpx -12rpx 18rpx -12rpx;
}
</style>
